'use strict';

import Base from './base';
import React from 'react';
import { IMG } from '../res';
import {
    Http
} from '../lib';
import {
    API
} from '../res';
import {browserHistory} from 'react-router'
import {
    UCheck,
    ButtonGroup,
    Button,
    Grid,
    Col,
    Input
} from 'amazeui-react';
import styles from '../../css/login.css';
export default class Login extends Base {
    constructor(props){
        super(props)
        this.state = {

        }
    }
    submit(){
        let mobile = this.refs.mobile.value;
        let pwd = this.refs.pwd.value;
        if(mobile==''){
            alert('请输入账号')
            return;
        }
        if(pwd==''){
            alert('请输入密码')
            return;
        }
        $.ajax({
            data: {username:mobile,password:pwd},
            type: 'POST',
            url: 'http://ddgl.dgjy.net:8008/index.php/api/index/verify',
            crossDomain: true,
            success: function(data) {
                localStorage.isLogs = 1;
                browserHistory.push("/DDStatistics");
                //location.href = location.href
            }
        });
        /*Http.post(API.login,{username:mobile,password:pwd},data=>{
            console.log(data);
            hashHistory.push('/DDStatistics');
            if(data.data.list.isLogin==1){
                hashHistory.push('/DDStatistics');
            }  else {
                alert('账户或密码有误')
            }
        })*/

    }
    render() {
        return(
            <div style={{overflow:'hidden'}}>
                <div className = {styles.header}><img src = {IMG.header}/></div>
                <div className = {styles.login}>
                    <img src={IMG.loginBg}/>
                    <div className = {styles.loginBox}>
                        <Grid className="doc-g">
                            <Col style={{fontSize:24,marginTop:27}} sm={12}>督导系统登录</Col>
                            <Col sm={12}><input ref='mobile' placeholder = '用户名' className = {styles.Account}/></Col>
                            <Col sm={12}><input type='password' ref='pwd' placeholder = '密码' className = {styles.password}/></Col>
                            <Col sm={6} className ={styles.remember}>
                            </Col>
                            <Col sm={6} className = {styles.forget}>忘记密码   ?</Col>
                            <Col  sm={12}><a className = {styles.submit} onClick={()=>{this.submit()}}>登录</a></Col>
                        </Grid>
                        <img className = {styles.accountImg} src= {IMG.account}/>
                        <img className = {styles.passwordImg} src= {IMG.password}/>
                    </div>
                </div>
                <div> <img src = {IMG.introduce}/></div>
            </div>
        )
    }
};
